package com.gitee.openviducn.inspector.common;

import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 业务异常
 * @Author: https://gitee.com/wesleyOne
 * @Date: 12.07 2019
 */
public class BizException extends Exception implements Serializable {

    private static final long serialVersionUID = 2007525058641283836L;

    private String code;

    private BizException(@NotNull String code, Object msg) {
        super(msg.toString());
        this.code = code;
    }

    public BizException(@NotNull ResponseError responseError) {
        this(responseError.getCode(), responseError.getMsg());
    }

    public BizException(@NotNull ResponseError responseError, @NotNull Object... msgs) {
        this(responseError.getCode(), responseError.getMsg().concat("#")
                .concat(StringUtils.join(msgs, "#")));
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

}
